<?php
class MHDEV_Acl extends Zend_Acl 
{
	public function __construct()
	{
		// module
		$this->add(new Zend_Acl_Resource('default'));
		$this->add(new Zend_Acl_Resource('backend'));
		
		// roles
		$this->addRole(new Zend_Acl_Role('guest'));
		$this->addRole(new Zend_Acl_Role('user'), 'guest');
		$this->addRole(new Zend_Acl_Role('moderator'), 'user');
		$this->addRole(new Zend_Acl_Role('admin'), 'user');
		
		// resources
		$this->add(new Zend_Acl_Resource('default.error'), 'default');
		$this->add(new Zend_Acl_Resource('default.index'), 'default');
		$this->add(new Zend_Acl_Resource('default.posts'), 'default');
		$this->add(new Zend_Acl_Resource('default.categories'), 'default');
		$this->add(new Zend_Acl_Resource('default.boards'), 'default');
		$this->add(new Zend_Acl_Resource('default.threads'), 'default');
		$this->add(new Zend_Acl_Resource('default.login'), 'default');
		$this->add(new Zend_Acl_Resource('default.register'), 'default');
		$this->add(new Zend_Acl_Resource('default.profile'), 'default');
		$this->add(new Zend_Acl_Resource('default.groups'), 'default');
		$this->add(new Zend_Acl_Resource('default.messages'), 'default');
		$this->add(new Zend_Acl_Resource('default.user'), 'default');
		$this->add(new Zend_Acl_Resource('default.rate'), 'default');
		$this->add(new Zend_Acl_Resource('default.install'), 'default');
		$this->add(new Zend_Acl_Resource('default.feed'), 'default');
		
		$this->add(new Zend_Acl_Resource('backend.index'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.navigation'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.ban'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.boards'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.categories'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.error'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.groups'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.log'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.permissions'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.posts'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.rank'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.settings'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.smilies'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.themes'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.threads'), 'backend');
		$this->add(new Zend_Acl_Resource('backend.user'), 'backend');
		
		// rules
		$this->allow('guest', 'default.index');
		$this->allow('guest', 'default.error');
		$this->allow('guest', 'default.posts', array('index', 'getLastPost'));
		$this->allow('guest', 'default.threads', array('index', 'add'));
		$this->allow('guest', 'default.login');
		$this->allow('guest', 'default.register');
		$this->allow('guest', 'default.profile', array('index', 'guestbook'));
		$this->allow('guest', 'default.user', array('index', 'online'));
		$this->allow('guest', 'default.install');
		$this->allow('guest', 'default.feed');
		
		$this->allow('user', 'default.profile', array('edit', 'avatar', 'deleteguestbookentry', 'addbuddy', 'setbuddy'));
		$this->allow('user', 'default.posts');
		$this->allow('user', 'default.messages', array('index', 'outbox', 'show', 'reply', 'delete'));
		$this->allow('user', 'default.threads');
		$this->allow('user', 'default.rate');
		
		$this->allow('moderator', 'backend.index');
		$this->allow('moderator', 'backend.navigation', array('frontend', 'requestfrontend', 'deletefrontend', 'mode'));
		$this->allow('moderator', 'backend.ban');
		$this->allow('moderator', 'backend.error');
		$this->allow('moderator', 'backend.log');
		$this->allow('moderator', 'backend.posts');
		$this->allow('moderator', 'backend.rank');
		$this->allow('moderator', 'backend.smilies');
		$this->allow('moderator', 'backend.threads');
		
		// admin
		$this->allow('admin');
	}
}
?>